package com.example.bishe.controller.Test;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.bishe.entity.*;
import com.example.bishe.mapper.Bzks_bjMapper;
import com.example.bishe.service.Zxbz_dwService;
import com.example.bishe.service.impl.*;
import com.example.bishe.toolclass.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author yws
 * @Date 2022/3/20 10:49
 */
@RestController
public class SelectBm {
    @Resource
    GitTonk gitTonk;
    @Resource
    ApiReturnDate apiReturnDate;
    @Autowired
    Zxbz_dwService zx = new Zxbz_dwServiceImpl();

    /*@RequestMapping("/test3076")//插入部门3076
    public void set3076(){
        //获取token
        String access_token = gitTonk.AccessToken("useraccess_token");
       *//* if (redisUtil.get("useraccess_token") == null) {
            access_token = gitTonk.gitTongXunTonk();
        } else {
            access_token = redisUtil.get("useraccess_token");
        }*//*
        //System.out.println(access_token);

        //拼接访问的URL
        String user =  MyEnum.DEPARTMENT_CAOZUO.getValue()+"create?" +
                "access_token="+access_token;
        //需要插入的组织额信息
        Map<String, String> map = new HashMap<>();
        map.put("name","中工");map.put("parentid","1");map.put("id","3076");
        //Map转为字符串然后转为JSON
        String str = JSON.toJSONString(map);
        JSONObject json = JSONObject.parseObject(String.valueOf(str));

        JSONObject mydate = apiReturnDate.Mydate(user,str);
        System.out.println(mydate);
    }*/
    /*@Autowired
    RedisUtil redisUtil;
    @RequestMapping("/test3077")//插入部门*/
  /*  public void set3077(){
        //获取token
        String access_token = gitTonk.AccessToken("useraccess_token");
        if (redisUtil.get("useraccess_token") == null) {
            access_token = gitTonk.gitTongXunTonk();
        } else {
            access_token = redisUtil.get("useraccess_token");
        }
        //System.out.println(access_token);
        //拼接访问的URL
        String user =  MyEnum.DEPARTMENT_CAOZUO.getValue()+"create?" +
                "access_token="+access_token;
        Map<String, String> map = new HashMap<>();
        map.put("name","计算机学院");map.put("parentid","3076");map.put("id","3163");
        String str = JSON.toJSONString(map);
        JSONObject json = JSONObject.parseObject(String.valueOf(str));
        JSONObject mydate = apiReturnDate.Mydate(user,str);
        System.out.println(mydate);

        map.put("name","新闻与传播学院");map.put("parentid","3076");map.put("id","3158");
        str = JSON.toJSONString(map);
        json = JSONObject.parseObject(String.valueOf(str));
        mydate = apiReturnDate.Mydate(user,str);
        System.out.println(mydate);

        map.put("name","计算机学院教职工");map.put("parentid","3163");map.put("id","3077");
        str = JSON.toJSONString(map);
        json = JSONObject.parseObject(String.valueOf(str));
        mydate = apiReturnDate.Mydate(user,str);
        System.out.println(mydate);

        map.put("name","新闻与传播学院教职工");map.put("parentid","3158");map.put("id","3079");
        str = JSON.toJSONString(map);
        json = JSONObject.parseObject(String.valueOf(str));
        mydate = apiReturnDate.Mydate(user,str);
        System.out.println(mydate);

        map.put("name","计算机学院学生");map.put("parentid","3163");map.put("id","3078");
        str = JSON.toJSONString(map);
        json = JSONObject.parseObject(String.valueOf(str));
        mydate = apiReturnDate.Mydate(user,str);
        System.out.println(mydate);

        map.put("name","新闻与传播学院学生");map.put("parentid","3158");map.put("id","3080");
        str = JSON.toJSONString(map);
        json = JSONObject.parseObject(String.valueOf(str));
        mydate = apiReturnDate.Mydate(user,str);
        System.out.println(mydate);

    }
*/
  /*  @Autowired
    Bzks_yxServiceImpl yx;
    @RequestMapping("/test3078")//插入学院
    public void set3078(){
        String access_token = gitTonk.AccessToken("useraccess_token");
        //拼接访问的URL
        String user =  MyEnum.DEPARTMENT_CAOZUO.getValue()+"create?" +
                "access_token="+access_token;
        Bzks_yx[] arr = yx.selectAll();
        for (int i = 0; i < arr.length; i++) {
            Map<String, String> map = new HashMap<>();
            map.put("name",arr[i].getMc());
            map.put("parentid",arr[i].getWx_parentid()+"");
            map.put("order",arr[i].getPx()+"");
            map.put("id",arr[i].getWx_id()+"");
            //Map转为字符串然后转为JSON
            String str = JSON.toJSONString(map);
            JSONObject json = JSONObject.parseObject(String.valueOf(str));
            JSONObject mydate = apiReturnDate.Mydate(user,str);
            System.out.println(mydate);
        }
    }*/

   /* @Autowired
    Bzks_zyServiceImpl zy;
    @RequestMapping("/test3079")//插入专业
    public void set3079(){
        String access_token = gitTonk.AccessToken("useraccess_token");
        //拼接访问的URL
        String user =  MyEnum.DEPARTMENT_CAOZUO.getValue()+"create?" +
                "access_token="+access_token;
        Bzks_zy[] arr = zy.selectAll();
        for (int i = 0; i < arr.length; i++) {
            Map<String, String> map = new HashMap<>();
            map.put("name",arr[i].getMc());
            map.put("parentid",arr[i].getWx_parentid()+"");
            map.put("id",arr[i].getWx_id()+"");
            //Map转为字符串然后转为JSON
            String str = JSON.toJSONString(map);
            JSONObject json = JSONObject.parseObject(String.valueOf(str));
            JSONObject mydate = apiReturnDate.Mydate(user,str);
            System.out.println(mydate);
        }
    }*/
    /*@Autowired
    Bzks_bjServiceImpl bj;
    @RequestMapping("/test3070")//插入班级
    public void set3070(){
        String access_token = gitTonk.AccessToken("useraccess_token");
        //拼接访问的URL
        String user =  MyEnum.DEPARTMENT_CAOZUO.getValue()+"create?" +
                "access_token="+access_token;
        Bzks_bj[] arr = bj.selectAll();
        for (int i = 0; i < arr.length; i++) {
            Map<String, String> map = new HashMap<>();
            map.put("name",arr[i].getBjmc());
            map.put("parentid",arr[i].getWx_parentid()+"");
            map.put("id",arr[i].getWx_id()+"");
            //Map转为字符串然后转为JSON
            String str = JSON.toJSONString(map);
            JSONObject json = JSONObject.parseObject(String.valueOf(str));
            JSONObject mydate = apiReturnDate.Mydate(user,str);
            System.out.println(mydate);
        }
    }*/

   /* @Autowired
    Zsj_bzksServiceImpl bzks;
    @Autowired
    StringTurnJson stringTurnJson;
    @RequestMapping("/test001")//插入所有学生
    public void set3071(){
        String access_token = gitTonk.AccessToken("useraccess_token");
        //拼接访问的URL
        String user =  MyEnum.USER_CAOZUO.getValue()+"create?" +
                "access_token="+access_token;
        Zsj_bzks[] arr = bzks.selectAll();
        for (int i = 0; i < arr.length; i++) {
            Map<String, String> map = new HashMap<>();
            map.put("userid",arr[i].getXh());
            map.put("name",arr[i].getXm()+"");
            map.put("gender",arr[i].getXbdm()+"");
            map.put("email",stringTurnJson.getPinyin(arr[i].getXm()));
            map.put("department",arr[i].getBzks_bj().getWx_id()+"");
            //Map转为字符串然后转为JSONq
            String str = JSON.toJSONString(map);
            JSONObject json = JSONObject.parseObject(String.valueOf(str));
            JSONObject mydate = apiReturnDate.Mydate(user,str);
            System.out.println(mydate);
        }
    }*/

    /*@Autowired
    Zsj_jzgServiceImpl jzg;
    @RequestMapping("/test002")//插入所有教师
    public void set3072(){
        String access_token = gitTonk.AccessToken("useraccess_token");
        //拼接访问的URL
        String user =  MyEnum.USER_CAOZUO.getValue()+"create?" +
                "access_token="+access_token;
        Zsj_jzg[] arr = jzg.selectdw();
        for (int i = 0; i < arr.length; i++) {
            Map<String, String> map = new HashMap<>();
            map.put("userid",arr[i].getZgh());
            map.put("name",arr[i].getXm()+"");
            map.put("gender",arr[i].getXbdm()+"");
            map.put("email",arr[i].getEmail());
            map.put("department",arr[i].getZxbz_dw().getWx_id()+"");
            //Map转为字符串然后转为JSONq
            String str = JSON.toJSONString(map);
            JSONObject json = JSONObject.parseObject(String.valueOf(str));
            JSONObject mydate = apiReturnDate.Mydate(user,str);
            System.out.println(mydate);
        }
    }*/

}
